import java.util.Arrays;

public class SolutionLCP2 {
    public int[] fraction(int[] cont) {
        long c=cont[cont.length-1],d=1;
        for (int i=cont.length-2;i>=0;i--){
            long t=c;
            c=d;
            d=t;
            c=c+d*cont[i];
        }
        long m=gcd(c,d);
        return new int[]{(int)(c/m),(int)(d/m)};
    }

    private long gcd(long c, long d) {
        if (d>c){
            long t=d;
            d=c;
            c=t;
        }
        return d==0?c:gcd(d,c%d);
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new SolutionLCP2().fraction(new int[]{3, 2, 0, 2})));
    }
}
